﻿CREATE FUNCTION [dbo].[IsViewUnpublished]
(
	@userId UNIQUEIDENTIFIER
)
RETURNS BIT
AS
BEGIN
	DECLARE @result BIT = 0

	IF EXISTS (
				SELECT *
				FROM [dbo].[user_Role] AS r
				INNER JOIN [dbo].[user_User] AS u ON u.[Email] = r.[Email]
				WHERE u.[UserId] = @userId AND r.[Role] = N'Admin'
						)
	BEGIN
		SET @result = 1
	END

	RETURN @result
END
